<!doctype html>
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, max-scale=1, min-scale=1,user-scalable=no">
    <meta name="_token" content="{{ csrf_token() }}"/>

    <link href="{{env('CDN_RESOURCE')}}/css/mobile/mobile1.css?v={{config('app.version')}}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css">

    <title>Qkids久趣英语</title>

</head>
<body>

<div class="s-header">
    <div class="logo"></div>
    {{--@if($buyOption != 1 || $largeLimit['day'] === 0)--}}
        {{--<div id="switch-account" class="account white-btn " data-field="{{$recommendPlan}}">登录</div>--}}
    {{--@endif--}}
</div>


<div class="blue-bg">
    <div class="cover">
        <div class="b" style="font-family:MicrosoftYaHeiLight;font-weight: 200;">严选北美外教</div>
        <div class="m">在线授课</div>
        <div class="s">
            <span class="age">4-12</span>岁适用／精品小班低至<span class="age">40</span>元
        </div>


        <div class="home" style="position: relative;display: none;">
            <img src="{{env('CDN_RESOURCE')}}/img/mobile/family.png">
            <div class="play-icon" id="viewVideo"></div>
        </div>

    </div>
    <div class="white-padding home" style="display: none;"></div>
</div>

<div class="wrapper">

    <div class="section home" style="display: none;padding-top:0;">

        <div class="hot-offer">
            <div class="left">
                <span class="sign">¥</span><span class="money">{{$products[$recommendPlan]['total']}}</span>
            </div>

            <div class="right">
                @if($buyOption === 0 || $buyOption === 2)
                    <div class="up"> 新用户专享</div>
                @endif
                <div class="lesson-count">/{{$products[$recommendPlan]['duration']}}课时</div>
            </div>
        </div>

        <div class="apply-section">
        @if($buyOption == 1)
            @if($largeLimit['day'] === 0)
                <div class="reg-btn apply-btn large-buy " data-field="{{$recommendPlan}}">
                    立即报名
                </div>
            @else
                <div class="reg-btn apply-btn large-buy disable" data-field="{{$recommendPlan}}">
                    <span>距离下次报名还有</span>
                    <span>{{$largeLimit['day']}}</span>
                    <span>天</span>
                </div>
            @endif
        @else
            <div class="reg-btn apply-btn" data-field="{{$recommendPlan}}">
                立即报名
            </div>
        @endif
        </div>

        <div class="notice">
            @if($buyOption == 1 && $largeLimit['day'] > 0)
                <div class="text red">{{$largeLimit['next']}}开放购买</div>
            @else
                <div class="tag">
                    <div>第{{$batch[$recommendPlan]}}期</div>
                    <div></div>
                    <div></div>

                </div>
                <div class="text">限量招募500人，还剩 <span>{{empty($product[$recommendPlan]) ? 22 : $product[$recommendPlan]['left']}}</span> 人</div>
            @endif
        </div>

        <div class="features">
            <div class="item">
                <div class="graduation-icon icon"></div>
                <span>精选北美外教</span>
            </div>
            <div class="item">
                <div class="interest-icon icon"></div>
                <span>趣味教学场景</span>
            </div>
            <div class="item">
                <div class="level-icon icon"></div>
                <span>科学分级课程</span>
            </div>

            <div>
                <div class="connect-line"></div>
                <div class="connect-line"></div>
            </div>

        </div>
    </div>


    <div class="section teacher" style="display: none;">
        <div class="graduation-icon-c"></div>
        <div class="header">严选北美外教</div>
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/teacher.png">
        <div class="statistic">
            <div class="item">
                <div class="up">1%</div>
                <div class="down">考核通过率</div>
            </div>

            <div class="item">
                <div class="up">100%</div>
                <div class="down">来自美国，加拿大</div>
            </div>

            <div class="item">
                <div class="up">95+</div>
                <div class="down">家长评分</div>
            </div>

        </div>
    </div>

    <div class="section animation" style="display: none;">
        <div class="interest-icon-c"></div>
        <div class="header">趣味教学场景</div>
        <div class="sub-header">孩子到久趣的第一个转变—主动要求上课</div>
        <img src='{{env('CDN_RESOURCE')}}/img/mobile/teaching.png'>

        <div class="lesson-steps">
            <div class="item">
                <div class="photo-icon"></div>
                <div class="text">丰富动画</div>
            </div>


            <div class="item">
                <div class="game-icon"></div>
                <div class="text">游戏化</div>
            </div>


            <div class="item">
                <div class="thumbsup-icon"></div>
                <div class="text">同伴激励</div>
            </div>


        </div>
    </div>

    <div class="section">
        <div class="level-icon-c"></div>
        <div class="header">科学分级课程体系</div>
        <div class="sub-header">
            <span>基于欧洲语言共同框架(CEFR)独家研发，与中国公立小学新课标教材接轨，更适合中国孩子学习</span>
        </div>
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/course_system.png" style="margin-top: 22px;">
        <div class="sub-header">
            <span>即刻连线北美外教，专业指导，进阶升级。</span>
            <span>久趣英语目前已开设自然拼读课、语言基础课，还有更多好学好玩的课程等你发现。</span>
        </div>
    </div>


    <div class="section buy" style="display: none;">
        <div class="blue-divider"></div>
        <div class="header">特惠价格，即刻报名</div>
        <div class="sub-header">180天无条件退款，报名后即可上课</div>

        <div class="lesson-plan">

            <div class="detail product4 zoom-out">

                <div class="fee">
                        <span class="up">
                            ¥ <span class="money">100</span>
                        </span>
                    <span class="down">
                            /4 课时
                        </span>
                </div>

                <div class="schedule">
                    <div><span>自购买起，一个月内有效</span></div>
                    <div><span>建议4-6节课/周</span></div>
                    <div><span>本期招生仅限前500</span></div>
                    <div class="reg-btn buy-btn" data-field="4">购买</div>
                </div>

            </div>

            <div class=" detail zoom-in">

                <div class="fee">
                        <span class="up">
                            ¥ <span class="money">3500</span>
                        </span>
                    <span class="down">
                            /100 课时
                        </span>
                </div>

                <div class="schedule">
                    <div><span>自购买起，课时一年内有效</span></div>
                    <div><span>建议4-6节课/周</span></div>
                    @if($largeLimit['day'] > 0)
                        <div class="reg-btn buy-btn disable" data-field="6">待开放</div>
                    @else
                        <div class="reg-btn buy-btn" data-field="6">购买</div>
                    @endif
                </div>

            </div>

            <div class=" detail zoom-out">

                <div class="fee">
                        <span class="up">
                            ¥ <span class="money">1750</span>
                        </span>
                    <span class="down">
                            /50 课时
                        </span>
                </div>

                <div class="schedule">
                    <div><span>自购买起，课时90天内有效</span></div>
                    <div><span>建议4-6节课/周</span></div>
                    @if($largeLimit['day'] > 0)
                        <div class="reg-btn buy-btn disable" data-field="5">待开放</div>
                    @else
                        <div class="reg-btn buy-btn" data-field="5">购买</div>
                    @endif
                </div>

            </div>

        </div>
    </div>

    <div class="section">

        <div class="blue-divider"></div>
        <div class="header">简单<span>3</span>步，立即上课</div>

        <div class="lesson-steps" style="margin-top:10px;">
            <div class="item">
                <div class="ok-icon"></div>
                <span>购买课程</span>
            </div>

            <div class="item">
                <div class="chat-icon"></div>
                <span>微信约课</span>
            </div>

            <div class="item">
                <div class="tv-icon"></div>
                <span>进入教室</span>
            </div>
        </div>

        <div class="class-type">
            <div class="c-header">精品 二人班 四人班，每节课30分钟</div>
        </div>
    </div>

    <div class="section" style="display: none;">
        <div class="blue-divider"></div>
        <div class="header">家长说</div>
        <div class="review" id="review">
            <div class="left-r item ">
                <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar1.png"/>
                <div class="text">喜欢久趣，我们家一天一节课，孩子主动要求的。</div>

                <div class="review-who">
                    <span>Mike 的家长</span>
                </div>
            </div>

            <div class="right-r item ">

                <div class="text">全程课小孩自己上完了，完全没让我帮忙。</div>
                <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar2.png"/>

                <div class="review-who">
                    <span>Lorna 的家长</span>
                </div>
            </div>

            <div class="left-r item ">
                <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar3.png"/>
                <div class="text">现在上课已经成为了小朋友期盼的一件事，真不错！</div>

                <div class="review-who">
                    <span>Steve 的家长</span>
                </div>
            </div>

            <div class="right-r item ">

                <div class="text">外教的语音语调都很好听，很地道。</div>
                <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar4.png"/>

                <div class="review-who">
                    <span>Vincent 的家长</span>
                </div>
            </div>

            <div class="left-r item ">
                <img src="{{env('CDN_RESOURCE')}}/img/mobile/avatar5.png"/>
                <div class="text">孩子对语言很敏感，我希望他从小就接触纯正的表达。</div>

                <div class="review-who">
                    <span>Alina 的家长</span>
                </div>
            </div>

        </div>

    </div>
</div>

{{--@include('mobile.partial.loginAndRegister')--}}

<div class="footer">

    <div class="icon-links">
        <div class="logo-blue"></div>
    </div>

    <div class="email">
        <div class="header">企业邮箱</div>
        <div class="text">service@qkids.cn</div>
    </div>

    <div class="qr-code">
        <img src="{{env('CDN_RESOURCE')}}/img/mobile/qrcode.png"/>
        <span>微信公众号</span>
        <span>久趣英语服务号</span>
    </div>

    <div id="account-info" style="text-align: center;display: none;margin-top: 10px;color: #676C75;font-size: 14px;">
        当前账号: <span id="current-account"></span> | <span id="switch-account">切换账号</span>
    </div>

    <div class="copy-right">
        <span>Copyright @2017-2018 Qkids All Rights Reserved</span>
        <span>闽ICP备12021838号-3</span>
    </div>

</div>

<div class="video-mask" id="videoMask">
    <div class="close-icon icon" id="closeVideo"></div>
    <div id="videoContainer" class="video">
    </div>
</div>

<div class="buy-restrict">
    <div class="info">
        您已购买过¥100元/4课时，每人仅限购买1次，如有需要，可报名长期课。
    </div>

    <a href="/wx/vip"><div class="small-btn confirm-btn">前往购买</div></a>

</div>

<div class="account-mask">
    <div class="account-info">
        <div class="close-icon icon" id="closeAccount"></div>
        <div class="current-account">
            <span class="text">当前账号: </span>
            <span class="acc-id"></span>
        </div>
        <div style="margin: 0 auto;" class="reg-btn switch-account">切换账号</div>
    </div>
</div>

<div id="alertBox" class="alert-box"></div>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.2/weui.min.js"></script>

<!--引入微信js-SDK-->
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/wx_config.js?v={{config('app.version')}}"></script>

<script type="text/javascript" src="https://static-app.97kid.com/wx/js/zepto.min.js"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/Zepto_fx_methods.js"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/login.js?v={{config('app.version')}}"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/AV.analytics.js"></script>


<script type="text/javascript">

  ;(function ($) {

    $(function () {

      switch (location.pathname) {
        case '/wx/brand/teacher':   $('.teacher').show();$('.buy').show();  break;
        case '/wx/brand/animation': $('.animation').show();$('.buy').show();break;
        case '/wx/brand/levels':    $('.levels').show();$('.buy').show();   break;
        case '/wx/brand/buy':       $('.buy').show();                       break;
        default:                    $('.home').show();$('.teacher').show();$('.animation').show();$('.levels').show();$('.buy').show();     break;
      }
      var currentLevel = 1;
      var previousLevel = 1;
      var offset = 5;

      var isInWechat = false;
      var userAgent = navigator.userAgent;
      //var userAgent = "Mozilla/5.0(iphone;CPU iphone OS 5_1_1 like Mac OS X) AppleWebKit/534.46(KHTML,like Geocko) Mobile/9B206 MicroMessenger/5.0";
      var wechatInfo = userAgent.match(/MicroMessenger\/([\d\.]+)/i);
      if (wechatInfo) {
        isInWechat = true;
      }

      // 最简的示例代码，请换成自己的 appId 和 appKey
      var appId = 'antYy9lOFi5mkU9QKjtYmRLM-gzGzoHsz';
      var appKey = 'jqyWxLyobpsmdwsJddJlDheb';

      // 实例化统计分析功能（注意：实例化后，SDK 会自动开始统计 PV、UV、停留页面时长等信息）
      var analytics = AV.analytics({
        // 设置 AppId
        appId: appId,
        // 设置 AppKey
        appKey: appKey,
        // 你当前应用的渠道或者你想指定的渠道（自定义）
        channel: wechatInfo ? 'weixin' : ''
      });

      $('#left').hide();

      //  选择课程分级
      $('.level-slide-list span').click(function () {

        var nav = $(this);
        previousLevel = currentLevel;
        currentLevel = $(this).index() + 1;


        nav.addClass('active-level').siblings('span').removeClass('active-level');
        if (offset === currentLevel && (currentLevel !== 12 )) {

          $('#levelSlideList').animate(
            {
              left: -$('#firstLevel').width() * (offset - 1 )
            },
            {
              duration: 250, complete: function () {
              $('#unavCursor').animate({
                left: nav.offset().left - 0.05 * window.screen.width
              }, 250);
            }
            });

          offset = offset + ( 5 - 1 );

        } else if ((offset - 4) === currentLevel && (currentLevel !== 1 )) {

          $('#levelSlideList').animate(
            {
              left: -$('#firstLevel').width() * (offset - 9 )
            },
            {
              duration: 250, complete: function () {
              $('#unavCursor').animate({
                left: nav.offset().left - 0.05 * window.screen.width
              }, 250);
            }
            });

          offset = offset - ( 5 - 1 );

        } else {
          $('#unavCursor').animate({
            left: nav.offset().left - 0.05 * window.screen.width
          }, 250, function () {
          })
        }
        $('.level-info .level-item').eq(currentLevel - 1).addClass('active-level-item').siblings('.level-item').removeClass('active-level-item');

      });


      var totalPlans = 3;
      var clickItem = null;
      $('.lesson-plan .detail').on('click', function () {
        $(this).addClass('zoom-in').removeClass('zoom-out');
        $(this).siblings('div').each(function () {
          if ($(this).hasClass('zoom-in')) {
            $(this).removeClass('zoom-in').addClass('zoom-out');
          }
        })

        if ($(this).index() === ( totalPlans - 1 )) {
          clickItem = $('.lesson-plan .detail').eq(0);
          $('.lesson-plan .detail').eq(0).remove();
          $('.lesson-plan').append(clickItem);
        }

        if ($(this).index() === 0) {
          clickItem = $('.lesson-plan .detail').eq(totalPlans - 1);
          $('.lesson-plan .detail').eq(totalPlans - 1).remove();
          $('.lesson-plan').prepend(clickItem);
        }
      });


      var timeout;
      $(document).bind("scroll", function () {

        clearTimeout(timeout);
        timeout = setTimeout(function () {

          var reviewList = $('#review');
          if ($(window).scrollTop() > reviewList.offset().top - 300) {

            if (reviewList.css('visibility') === 'hidden') {
              reviewList.css('visibility', 'visible');
              reviewList.find('.item').each(function () {
                $(this).addClass('fade-animate');
              })
            }
          }
        }, 10);
      });

      var configOption = {
        timestamp: '{{$signature['timestamp']}}',
        nonceStr: '{{$signature['nonceStr']}}',
        signature: '{{$signature['signature']}}',
        jsApiList: ['onMenuShareTimeline', 'chooseWXPay', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareQZone']
      };
      var wxconfig = new WxConfig(configOption);
      var account = new Account({
        forceLogin: false
      });

      account.getUserInfo(function (err, result) {
        if (!err) {

            //获取推荐购买课时
            @if($buyOption == 2 )
                getRecommendations();
            @endif
            //配置微信分享接口
            if(isInWechat) {
                wxconfig.activeShare(result.shareFlag);
            }
        }

      });

      //切换账号
      $('.account').off('click').on('click',function() {
	      var mobile = window.localStorage.getItem("mobile");
	      if (!mobile) {
            switchAccount();

          } else {
		      $('.acc-id').text(window.localStorage.getItem('mobile'));
		      $('.account-mask').fadeIn();
	      }
      });

      $('#closeAccount').off('click').on('click',function(){
        $('.account-mask').fadeOut();
      })

      $('.switch-account').off('click').on('click', function () {
        $('.account-mask').fadeOut();
        switchAccount();
      });

      function switchAccount() {
        var accessString = window.localStorage.getItem(account.accessKey);
        if (accessString) {
          account.ajax({
            type:'DELETE',
            path:'/s/user/social/wx-jqfx',
            async:false
          })
        }
        localStorage.removeItem(account.accessKey);
        account._showLogin(function () {}, true);
      }

      //提交订单
      $('.apply-btn, .buy-btn, .apply-btn-s').off('click').on('click', function () {
        submitOrder($(this).attr('data-field'));
      });
      $('.disable').off('click');

      function getRecommendations() {

        account.ajax({
          type: 'GET',
          path: '/s/products/recommendations',
          success: function (result) {
            if(result.id != '{{$recommendPlan}}') {
                $('.hot-offer .right .up').hide();
                $('.hot-offer .money').text(result.price);
                $('.hot-offer .lesson-count').text('/' + result.lessonCount + '课时');
                $('.apply-btn-s, .apply-btn').attr('data-field',result.id);

                $('.apply-btn').addClass('large-buy');

                $('.notice .tag div:first-child').html('第{{$batch[6]}}期');
                $('.notice .text span').html('{{$product[6]['left']}}');

                @if($largeLimit['day'] > 0)
                    $('.apply-btn-s, .apply-btn').off('click');
                    $('.apply-btn').html('<span>距离下次报名还有</span> <span>{{$largeLimit['day']}}</span> <span>天</span>');
                    $('.notice').html('<div class="text red">{{$largeLimit['next']}}开放购买</div>');
                    $('.s-header .apply').hide();
                @else
                    $('.product4').removeClass('zoom-in').addClass('zoom-out');
                @endif
            }
          },
          error: function (err) {
            $.toastAlert(err.message, 2);
          }
        });
      }

      function submitOrder(pId) {
        account.forceLogin = true;
        //提交订单久趣后台
        account.getUserInfo( function (userInfoError, userInforesult){

          if(userInfoError) {
            $.toastAlert(userInfoError.message);
          } else {
            if (isInWechat) {
              //配置微信分享接口
              wxconfig.activeShare(userInforesult.shareFlag);
            }
            account.ajax({
              type: 'POST',
              path: '/s/bills',
              data: {
                productId: pId,
                payChannel: isInWechat ? 'weixin' : 'alipay',
                returnUrl: window.location.protocol + '//' + window.location.host + '/wx/verifypayment1/' + pId,
                tradeType: 'JSAPI',
                openId: window.localStorage.getItem(account.openId)
              },
              success: function (data) {
                //唤起微信支付
                if(data.status !== 'error') {
                  analytics.send({
                    // 事件名称
                    event: 'home-bill-success',
                    // 事件属性，任意数据
                    attr: {
                      productId: pId,
                      billId: data.bill_id,
                      isInWechat: isInWechat
                    }
                  });
                  if (isInWechat) {
                    var jsApiParameters = JSON.parse(data.jsApiParameters);
                    jsApiParameters.success = function() {
                      analytics.send({
                        // 事件名称
                        event: 'home-pay-success',
                        // 事件属性，任意数据
                        attr: {
                          productId: pId,
                          billId: data.bill_id,
                          isInWechat: isInWechat
                        }
                      });
                    };
                    jsApiParameters.fail = function() {
                      analytics.send({
                        // 事件名称
                        event: 'home-pay-fail',
                        // 事件属性，任意数据
                        attr: {
                          productId: pId,
                          billId: data.bill_id,
                          isInWechat: isInWechat
                        }
                      });
                    }
                    wxconfig.pay(data.bill_id, pId, jsApiParameters);
                  } else {
                    window.location.href = data.url;
                  }
                } else {
                  analytics.send({
                    // 事件名称
                    event: 'home-bill-fail',
                    // 事件属性，任意数据
                    attr: {
                      productId: pId,
                      billId: data.bill_id,
                      isInWechat: isInWechat
                    }
                  });
                  $.toastAlert('下单失败，请重试');
                }

              },
              error: function (err) {
                if (err.code === 'product.rejected.by.bought.products') {
                  $('.buy-restrict').fadeIn();
                }
                $.toastAlert(err.message, 2);
              }
            });

          }

        });
      }
    })

  })(window.Zepto);


</script>

<script src="//imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.2.1.js" charset="utf-8"></script>
<script>
    $(function () {
      //初始化视频
      var player = new TcPlayer(
        //页面放置播放位置的元素 ID
        "videoContainer",
	      {
          "m3u8": "http://1251352844.vod2.myqcloud.com/45f5686avodtransgzp1251352844/3b4dc3f34564972818953227732/v.f20.mp4",
		      "autoplay" : false,
		      "coverpic" : "",
		      "width" :  '640',
		      "height" : '480',
		      "live": false,
		      "systemFullscreen" : true,
	      });

      //观看视频
      $('#viewVideo').click(function () {
        $('#videoMask').fadeIn(300);
        player.play();
      });

      //关闭视频
      $('#closeVideo').click(function () {
        player.pause();
        $('#videoMask').fadeOut(300);
      })
    })
</script>

@include('template.ga')
</body>
</html>

